/*
 * @Description: 
 * @Author: yeeChen
 * @Date: 2022-12-21 16:23:41
 * @LastEditTime: 2022-12-21 16:33:52
 * @LastEditors: yeeChen
 */

// 导入queryString 模块
const qs = require('querystring')

// 定义解析函数

const bodyParmer = function (req, res, next) {
    
    let str = ''
    
    // 监听req的data
    req.on('data', function (chunk) {
        str += chunk
    })

    // 监听req的end请求
    req.on('end', function () {
        const body = qs.parse(str)
        req.body = body
        next()

    })
}

// 导出当前模块
module.exports = bodyParmer